package com.itheima.controller;

import com.itheima.entry.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author jshstart
 * @creat 2020-11-15 20:09
 */
@RestControllerAdvice
public class GlobalExceptionInvoker {
    @ExceptionHandler
    public Result handleException(Exception ex){
        ex.printStackTrace();
        String _message=null;
        if (ex.getMessage().length()>200){
            _message=ex.getMessage().substring(0,200);
        }else {
            _message=ex.getMessage();
        }
        return new Result(false,_message);
    }

}
